<?php
class SingleHand{
	public $cards;
	
	// Costruttore
	function __construct($cards = null){
		if($cards == null){
			$this->cards = null;
		}else{
			foreach($cards as $c){
				$this->cards[] = $c;
			}
		}
		
	}
	
	// Aggiunge una singola carta alle carte del round
	function takeCard($card){ 
		$this->cards[] = $card;
	} 
	
	function discardCard($card,$mode=1){ //mode = 1, first and only card. mode = 0, all cards matching
		reset($this->cards); // guarantee first element is indexed
		while ((list($key, $element) = each($this->cards))){
			if($element === $card){
				unset($this->cards[$key]); // remove card
				$this->cards = array_values($this->cards); // reindex array
				if($mode == 1){
					break; // found first one now stop
				} 
			}
		}
	}
	
	function total() {
		// @FIXME torna il totale di ogni singolo round 
	}
	
	// Getter e setter delle carte
	
	function setCards($cards){ 
		$this->cards = $cards;
	}
	
	function getCards(){
		return $this->cards;
	}
	
}
?>
